import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class TitleView extends StatelessWidget {
  const TitleView({
    super.key,
    required this.title,
    this.rightTitle,
    this.onRightTap,
    this.onLeftTap,
  });

  final String title;
  final String? rightTitle;
  final GestureTapCallback? onLeftTap, onRightTap;

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        Align(
          alignment: Alignment.centerLeft,
          child: GestureDetector(
            onTap:
                onLeftTap ??
                () {
                  Navigator.pop(context);
                },
            child: Image.asset(
              'assets/images/jiantoubai.png',
              width: 20,
              height: 20,
            ),
          ),
        ),
        Text(title, style: TextStyle(fontSize: 18, color: Colors.white)),
        Align(
          alignment: Alignment.centerRight,
          child: GestureDetector(
            onTap: onRightTap,
            child: Text(rightTitle ?? '', style: TextStyle(fontSize: 18)),
          ),
        ),
      ],
    );
  }
}
